package cn.com.gas.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;

import cn.com.common.result.DataResult;
import cn.com.gas.entity.GasMineExportEntity;
import cn.com.gas.service.GasMineExportService;
import cn.com.system.service.impl.HttpSessionService;



/**
 * 我的导出
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2024-12-05 22:23:53
 */
@RestController
@RequestMapping("/gas/mineExport")
public class GasMineExportController {
    @Autowired
    private GasMineExportService gasMineExportService;
    @Autowired
	private HttpSessionService httpSessionService;

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        gasMineExportService.removeByIds(ids);
        return DataResult.success();
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "查询分页数据")
    @PostMapping("/list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody GasMineExportEntity gasMineExport){
    	String currentUserId = httpSessionService.getCurrentUserId();
    	
    	Page page = new Page(gasMineExport.getPage(), gasMineExport.getLimit());
        LambdaQueryWrapper<GasMineExportEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        queryWrapper.eq(GasMineExportEntity::getCreateId, currentUserId);
        
        queryWrapper.orderByDesc(GasMineExportEntity::getCreateTime);
        IPage<GasMineExportEntity> iPage = gasMineExportService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
